package edu.ntu.im.p2ptrade.action;

import javax.servlet.http.HttpServletRequest;

import edu.ntu.im.p2ptrade.TransactionManager;

public class DenyOrApproveTRequest extends AjaxAction{

	@Override
	public AjaxResponse execute(HttpServletRequest request) {
		boolean approve = Boolean.parseBoolean(request.getParameter("approve"));
		String transactionId = request.getParameter("transactionId");
		if (approve){
			TransactionManager.getInstance().approveRequest(transactionId);
			return success("Transaction no.:"+transactionId+" has been approved, waiting for the transaction to complete!");
		}else {
			TransactionManager.getInstance().denyRequest(transactionId);
			return success("Transaction no.:"+transactionId+" has been denied.");
		}
		
	}

}
